# coding:utf-8
import time

from lib.base_ios import Base

from page.ios import train_12306_order_fill_page, train_fare_details_page, train_rush_order_fill_page, \
    train_qunar_order_fill_page

__author__ = 'weixin.yuan'


class TrainFareDetails(Base):
    """补票车次详情"""
    def __init__(self, method_name):
        Base.__init__(self, method_name)

        """
        本页元素
        """
        self.qiangpiao_btn = train_fare_details_page.elements['抢票']
        self.yuding_btn = train_fare_details_page.elements['预定']
        self.shikebiao_btn = train_fare_details_page.elements['时刻表']
        self.qunar_yuding_btn = train_fare_details_page.elements['去哪儿快速预订']
        self.yuding_12306_btn = train_fare_details_page.elements['12306预订']

        """
        外部页面元素
        """
        self.qiangpiao_title = train_rush_order_fill_page.elements['填写抢票信息title']
        self.qunar_order_title = train_qunar_order_fill_page.elements['订单填写']
        self.order_12306_title = train_12306_order_fill_page.elements['订单填写']

    def test_Fare_details(self):
        """补票车次详情页check"""
        self.open_schema_ios('6010')

        self.click(self.shikebiao_btn)
        time.sleep(3)
        self.back()

        if self.is_exits(self.qiangpiao_btn):
            self.click(self.qiangpiao_btn)
            self.check(self.qiangpiao_title)
            time.sleep(3)
            self.back()

        if self.is_exits(self.yuding_btn):
            self.click(self.yuding_btn)
            self.click(self.qunar_yuding_btn)
            self.check(self.qunar_order_title)
            self.back()
            self.click(self.yuding_12306_btn)
            self.check(self.order_12306_title)
